/**
 * MessageFactory handles messages by creating a specific Message type for each message.
 * @author Anthony Turner
 *
 */
public class MessageFactory{
	
	private static MessageFactory mf;//Single MessageFactory object

	//Private constructor
	private MessageFactory(){}
	
	/**
	 * Precondition: A static call is made on this class and method
	 * PostCondition: A single instance of a MessageFactory is returned
	 * @return returns a single instance of a MessageFactory
	 */
	public static MessageFactory getInstance(){
		
		//If there is no instance of MessageFactory, then create one and only one instance.
		if( mf == null)
			mf = new MessageFactory();
		
		return mf;
	}
	

	/**
	 * Creates a message depending on the argument value type
	 * @param msg the income message to create a Message from.
	 * @return returns a message of a specific type
	 */
	public MessageInterface createMessage(String msg) {
		
		
		if( msg.equals("0")){
			
			return new ScanMessage(msg);
		}else
			return new TuneMessage(msg);

	}

}
